package cn.spring.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.spring.bean.Address;
import cn.spring.dao.AddressMapper;
import cn.spring.service.AddressService;

@Service
@Transactional
public class AddressServiceImpl implements AddressService {
	@Resource
	private AddressMapper dao;
	
	@Override
	public int addressCount(Integer empId) {
		// TODO Auto-generated method stub
		return dao.addressCount(empId);
	}

	@Override
	public int save(Address add) {
		// TODO Auto-generated method stub
		dao.updateMo(add.getEmpId());
		return dao.insert(add);
	}

	@Override
	public List<Address> getAll(Integer empId) {
		// TODO Auto-generated method stub
		return dao.getAll(empId);
	}

	@Override
	public int updateMo(int empId) {
		// TODO Auto-generated method stub
		return dao.updateMo(empId);
	}

	@Override
	public int delete(int id) {
		// TODO Auto-generated method stub
		return dao.deleteByPrimaryKey(id);
	}

	@Override
	public Address selectMo(int empId) {
		// TODO Auto-generated method stub
		return dao.selectMo(empId);
	}

	@Override
	public void updateIsmoById(Integer id,Integer empId) {
		// TODO Auto-generated method stub
		dao.updateAllIsmo(empId);
		dao.updateIsmoById(id);
	}

}
